package aerith.components;

import java.awt.Image;
import java.beans.PropertyEditorManager;
import java.beans.SimpleBeanInfo;
import java.io.IOException;

public class GenericBeanInfo extends SimpleBeanInfo {

	public GenericBeanInfo(String s, boolean flag) {
		try {
			iconColor16 = loadImage("/aerith/swing/" + s + "Color16.png");
			iconColor32 = loadImage("/aerith/swing/" + s + "Color32.png");
		} catch (RuntimeException runtimeexception) {
			System.out.println("GenericBeanInfo.GenericBeanInfo(): "
					+ runtimeexception);
		}
		if (flag)
			PropertyEditorManager.registerEditor(java.util.Locale.class,
					aerith.components.LocaleEditor.class);
	}

	@Override
	public Image loadImage(String resourcePath) {
		java.net.URL imageurl = this.getClass().getResource(resourcePath);
		Image result = null;
		try {
			result = javax.imageio.ImageIO.read(imageurl);
		} catch (IOException e) {
			e.printStackTrace();
		}
		return result;
	}

	public Image getIcon(int i) {
		switch (i) {
		case 1:
			return iconColor16;

		case 2:
			return iconColor32;

		case 3:
			return iconColor16;

		case 4:
			return iconColor32;
		}
		return null;
	}

	protected Image iconColor16;
	protected Image iconColor32;
}
